feat(issues): add batch_update_issue_labels granular tool - #3149
Open
CAOShurong wants to merge 1 commit into
Open
feat(issues): add batch_update_issue_labels granular tool#3149CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
Add a feature-flagged batch labeling tool that applies add/remove label
operations to multiple issues in a single MCP call, avoiding N sequential
update_issue_labels round-trips for bulk triage workflows (e.g. 'label all
issues from milestone X as priority/high').
- Each operation entry targets one issue with add and/or remove arrays;
labels not named in the operation are left untouched.
- All input is validated before any mutation: empty operations, duplicate
issue numbers, missing add/remove, and empty label names fail the whole
call up front. Per-issue API errors are reported individually in the
JSON result with applied/error per issue.
- Add phase uses POST /issues/{n}/labels (additive) and returns the full
resulting label set; remove phase uses DELETE per label.
Closes github#2412
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2412
Summary
Adds a feature-flagged granular tool
batch_update_issue_labelsthat applies label changes to multiple issues in a single MCP call. Today the only path for bulk labeling is N sequentialupdate_issue_labelscalls, which is exactly the friction described in #2412 (label all issues from milestone X aspriority/highforces either N noisy round-trips or dropping out of the MCP-first pattern to script theghCLI).Design
operationstargets one issue withaddand/orremovelabel arrays. Labels not named in an operation are left untouched — this is add/remove semantics (POST/DELETE .../issues/{n}/labels), not replace semantics.operations, duplicate issue numbers, entries missing bothaddandremove, and empty label names fail the whole call before any mutation is attempted, with an index-addressed error (operations[2]: duplicate issue_number 7...) pointing at the exact entry.{"issue_number":3,"applied":false,"error":"add failed: ..."}) instead of losing the successful work; overall result is marked as an error so the client knows to inspect it.The add phase returns GitHub's full resulting label set per issue, so callers can verify final state without a follow-up read.
This follows the existing granular-tools pattern: registered in the issues toolset, gated behind
FeatureFlagIssuesGranular, mutually exclusive with the consolidatedissue_write.Testing
batch_labels_granular_test.go): happy path across two issues (one add + one remove, request bodies asserted), plus rejection cases for every validation rule and a partial-failure case assertingIsError+ per-issue error text — 8 subtests, all passing.granular_tools_test.gotoolset inventory + toolsnap snapshot committed.go build ./...,golangci-lint run pkg/github/...: no new findings on changed files (remaining hits pre-exist on cleanmain, verified by stash comparison)../pkg/github/suite: only failures are 6 environment-dependent golden snapshot tests that reproduce identically on cleanmain(Windows CRLF snapshot artifacts), untouched by this change.Example
{ "owner": "org", "repo": "repo", "operations": [ {"issue_number": 10, "add": ["sprint-42"]}, {"issue_number": 15, "add": ["breaking-change"], "remove": ["needs-triage"]}, {"issue_number": 20, "remove": ["stale"]} ] }